/**
 * Class: FlickeringDot
 *
 * Purpose: 
 *
 * Created: Jan 27, 2010 @ 10:40:32 AM
 * @author Ken Scott
 */
package org.openfantasia.ps.shape;

import org.openfantasia.ps.particle.Particle;
import org.openfantasia.ps.shape.Dot;
import org.openfantasia.ui.PColor;
import org.openfantasia.ui.PFrame;
import org.openfantasia.util.math.PMath;

public class FlickeringDot extends Dot {

	public FlickeringDot(PFrame frame) {
		super(frame);
	}


	public FlickeringDot(PFrame frame, float weight) {
		super(frame, weight);
	}


	public void draw(Particle particle) {
		PColor c;
		if (PMath.randomBoolean()) {
			PColor color = PMath.randomBoolean() ? particle.getFillColor() : PColor.BLACK;
			PColor scaledColor = color.scale((float) particle.getBrightness());
			c = scaledColor.opacify((float) particle.getOpacity());
		}
		else {
			c = PColor.BLACK;
		}
		frame.strokeWeight(weight);
		frame.stroke(c);
		frame.point(particle.getPosition());
		frame.strokeWeight(1);
	}
}
